// pages/mine/index.js
const app = getApp()
Page({
  ...app.globalData.function,
  data: {
    ...app.globalData.config,
    list: [],
  },

  onChange(event) {
    // 需要手动对 checked 状态进行更新
   let id=event.currentTarget.dataset.id
   let check=event.detail
   let list=this.data.list
   let status=0
   for (let j = 0; j < list.length; j++) {
      if(list[j].id==id){
        list[j].status=check
      }
   }
   this.setData({list})
   if(check) status=1
   else status=0
   this.editCooper({id,status}).then(res=>{
        this.$showToast(res.resMessage)
   })
   
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
   
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    let that=this    
    let token=that.getStorage('user_info').wx_openid
    that.JoinCooper({token:token}).then(res=>{
       if(res.resCode=='9999'){
         that.setData({
           list:res.data.data
         })
       }
    })

  },

})